MAKEPAL Weird Palindrome Making - CodeChef Solution


Implementation basic

Python Code:

t=int(input())
for _ in range(t):
    number=int(input())
    arr=list(map(int,input().split()))
    odd=0
    total=0
    for num in arr:
        if num%2!=0:
            odd+=1
        total+=num
    
    if number==1:print(0)
    elif number==2 and odd==1:print(0)
    elif total%2==0:
        print(odd//2)
    elif total%2!=0:
        print((odd-1)//2)


Comments

Submit
0 Comments
More Questions

60. Permutation Sequence
42. Trapping Rain Water
32. Longest Valid Parentheses
Cutting a material
Bubble Sort
Number of triangles
AND path in a binary tree
Factorial equations
Removal of vertices
Happy segments
Cyclic shifts
Zoos
Build a graph
Almost correct bracket sequence
Count of integers
Differences of the permutations
Doctor's Secret
Back to School
I am Easy
Teddy and Tweety
Partitioning binary strings
Special sets
Smallest chosen word
Going to office
Color the boxes
Missing numbers
Maximum sum
13 Reasons Why
Friend's Relationship
Health of a person